home *** CD-ROM | disk | FTP | other *** search
- Path: wmin.ac.uk!usenet
- From: Idoia Lertxundi <gsoec@wmin.ac.uk>
- Newsgroups: comp.lang.c
- Subject: (no subject)
- Date: 15 Apr 1996 12:07:11 GMT
- Organization: Westminster University
- Message-ID: <4kte5f$1t2@badger.wmin.ac.uk>
- NNTP-Posting-Host: ux213.wmin.ac.uk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3_U1 sun4m)
- X-URL: news:comp.lang.c/154383-154482
-
- Hi C sufferers/lovers,
-
- I am working in the C program and I have come accross a weird prob.
- Rather than sending you code I will explain it in English as I have
- accurately located the problem.
-
- I have a list which is being created dinamycally and a pointer pointing to
- the head of the list.
-
- ptr=AllocateSpaceforptr();
- head=ptr;
-
- head ptr....ptr
- | ! ! |
- {}-{}-{}-NULL
-
- 1 2 3 4
-
- When I have put data in node number 3 I allocate with a malloc call
- node number 4 and as the function do not find suitable data to put
- in number 4 after a for loop I assign it to NULL. i.e.
-
- ptr=(FILEMODULE *)NULL;
-
- When I do printfs I see that the list of ptr corresponds to what I was
- expecting the above picture when I print out the content of the head pointer
- list
- which points to the begining of the ptr list the result is unexpected.
- i.e.
-
- head
- |
- {}-{}-{}-[not defined] the last node instead of being NULL is not defined.
-
-
- 1 2 3 4
-
- By not defined I mean that is a if after malloc there has not been anything
- put in there although I put the NULL which shows perfectly well in the ptr
- list. Somehow the head list is not receiving the NULL asigment. WHY??
-
- Any ideas you please mail me. I am sending this to a Newsgroup too.
-
- Thank you.
-
- P.S. The order is Read data to allocated, allocate a new one and traverse.
-
- --
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Ms Idoia Lertxundi . ,
- .:/
- e-mail: gsoec@wmin.ac.uk . ,,///;, ,;/
- URL : http://www.wmin.ac.uk/~gsoec/ . o:::::::;;///
- >::::::::;;\\\
- `'\\\\\'" `;\
- `;\
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- "All philosophy," I told her, "is based on two things only:
- curiosity and poor eyesight; if you had better eyesight you could see
- perfectly well whether or not these stars are solar systems, and if
- you were less curious you wouldn't care about knowing, which amounts
- to the same thing. The trouble is, we want to know more than we can see."
-
- Bernard de Fontanelle, Conversations on the Plurality of Worlds.
-
-